/*
 * ConfigCb.h
 *
 *  Created on: 2023年3月29日
 *      Author: 15271
 */

#ifndef TRUNK_SRC_CONFIGCB_H_
#define TRUNK_SRC_CONFIGCB_H_
#include <mutex>
#include "json.h"

namespace Media{
using namespace std;


#define RESETGPIO_ROOMS  23
#define CONNECTGPIO_ROOMS  112

#define RESETGPIO_AIR   49


static const string removeCmd = "find /mnt/mtd/Config -type f ! -name \"netWork.ini\"|xargs rm -f && rm -rf /extern/backups/mtd/Config";
//static const string removeCmd = "rm -rf /mnt/mtd/Config /extern/backups/mtd/Config";

class ConfigCb{
public:
	static ConfigCb *instance();
private:
	void initConfig();
	bool onConfigWifi(const std::string &name, const Json::Value &newTable, const Json::Value &oldTable, int &result);
	bool onPassword(const std::string &name, const Json::Value &newTable, const Json::Value &oldTable, int &result);
	bool onDevName(const std::string &name, const Json::Value &newTable, const Json::Value &oldTable, int &result);
	bool onAPInfo(const std::string &name, const Json::Value &newTable, const Json::Value &oldTable, int &result);
	bool onToken(const std::string &name, const Json::Value &newTable, const Json::Value &oldTable, int &result);
	bool onMirror(const std::string &name, const Json::Value &newTable, const Json::Value &oldTable, int &result);
	bool onLedSw(const std::string &name, const Json::Value &newTable, const Json::Value &oldTable, int &result);
	bool onOverlay(const std::string &name, const Json::Value &newTable, const Json::Value &oldTable, int &result);
	bool onVolume(const std::string &name, const Json::Value &newTable, const Json::Value &oldTable, int &result);
	bool onURL(const std::string &name, const Json::Value &newTable, const Json::Value &oldTable, int &result);

	ConfigCb();
	~ConfigCb();

	static bool resetConfig();
private:
	static ConfigCb *sm_configCb;
	static mutex    sm_instanceLock;
};
}



#endif /* TRUNK_SRC_CONFIGCB_H_ */
